﻿using EzDesk.Core.Model;
using EzDesk.DesktopClient.AppModule.ViewContract;
using EzDesk.DesktopClient.Command;
using EzDesk.DesktopClient.Event;
using EzDesk.MVVMBase;
using EzDesk.DesktopClient.MVVMEnhance;
using EzDesk.DesktopClient.ServiceLocator.CoreClientService;

namespace EzDesk.DesktopClient.AppModule.ViewModel
{
    public class AppFunctionViewModel : ViewModelBase
    {
        public AppFunction AppFunctionModel { get; set; }
        public DelegateCommand CallAppFunctionCommand { get; private set; }
        public AppFunctionViewModel(AppFunction appFunctionModel)
        {
            AppFunctionModel = appFunctionModel;
            CallAppFunctionCommand = new DelegateCommand(this.OnCallAppFunction);
        }

        private void OnCallAppFunction()
        {
            AppFunctionSelectedEvent.Instance.Publish(AppFunctionModel);
            FunctionNavigateEvent.Instance.Publish(new FunctionNavigateArgs() { Url = AppFunctionModel.TargetUrl });
        }
    }
}